package com.haoshuang.zhouzhoubang.ui.vm

import androidx.lifecycle.rxLifeScope
import com.haoshuang.zhouzhoubang.base.request
import com.haoshuang.zhouzhoubang.model.bean.TeamGroupBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData


class RemoveMemberViewModel : BaseViewModel() {

    /**
     * 根据分组id查询成员列表
     */
    val getmemberListWithGroupIdData = StatefulMutableLiveData<MutableList<TeamGroupBean.Member>>()
    fun getmemberListWithGroupId(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<MutableList<TeamGroupBean.Member>>("api/team/get_team_group_member", *params,
                onStart = {
                    getmemberListWithGroupIdData.value = StateData.Loading
                },
                onError = { code, msg ->
                    getmemberListWithGroupIdData.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getmemberListWithGroupIdData.value = StateData.Success(it)
                })
        }
    }

}